/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 28/05/2010, 16:42:21
 */
package virtual.view;

import java.awt.Frame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;

/**
 *
 * @author Rafael
 */
public class Principal extends javax.swing.JFrame {

    /** Creates new form Principal */
    public Principal() {
        initComponents();
    } // Fim do construtor
    
    
    /**
     * Adiciona um novo painel.
     * @param painel novo painel sendo adicionado.
     */
    public static void abreNovaJanelaInterna(JPanel painel) {
        
        // Limpa a tela
        JInternalFrame[] listaFrames = jdpPrincipal.getAllFrames();
        for (int i=0; i<listaFrames.length; i++) {
            listaFrames[i].dispose();
        } // Fim do for
        
        // Insere o novo painel
        painel.setVisible(true);

        JInternalFrame jif = new JInternalFrame();

        jif.add(painel);
        jif.pack();
        jif.setVisible(true);
        jif.setClosable(true);
        jdpPrincipal.add(jif);
        
        
    } // Fim do método abre NovaJanelaInterna
    
    
    /**
     * Adiciona um novo painel.
     * @param painel novo painel sendo adicionado.
     */
    public static void abreNovaJanelaInterna(JPanel painel, String titulo) {
        
        // Limpa a tela
        JInternalFrame[] listaFrames = jdpPrincipal.getAllFrames();
        for (int i=0; i<listaFrames.length; i++) {
            listaFrames[i].dispose();
        } // Fim do for
        
        // Insere o novo painel
        painel.setVisible(true);

        JInternalFrame jif = new JInternalFrame();

        jif.add(painel);
        jif.pack();
        jif.setVisible(true);
        jif.setClosable(true);
        jif.setTitle(titulo);
        jdpPrincipal.add(jif);
        
        
    } // Fim do método abre NovaJanelaInterna
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jdpPrincipal = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jdpPrincipal.setBackground(new java.awt.Color(212, 208, 200));
        jdpPrincipal.setName("jdpPrincipal"); // NOI18N
        getContentPane().add(jdpPrincipal, java.awt.BorderLayout.CENTER);

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu2.setText("Menu Cadastro");
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem1.setText("Cadastro de turma");
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuItem2.setText("Cadastro de Curso");
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuItem5.setText("Cadastro de Aluno");
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        jMenu1.setText("Notas alunos");
        jMenu1.setName("jMenu1"); // NOI18N

        jMenuItem3.setText("Divulagar Notas");
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Ajuda");
        jMenu3.setName("jMenu3"); // NOI18N

        jMenuItem4.setText("Sobre");
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem4);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-808)/2, (screenSize.height-648)/2, 808, 648);
    }// </editor-fold>//GEN-END:initComponents
int a = 0;
    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed



        CadastroPessoa cad = new CadastroPessoa();



        cad.setVisible(true);

        JInternalFrame jif = new JInternalFrame();

        jif.add(cad);
        jif.pack();
        jif.setVisible(true);
        jif.setClosable(true);
        this.jdpPrincipal.add(jif);






    }//GEN-LAST:event_jMenuItem5ActionPerformed

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
    
    CadastroTurma cad = new CadastroTurma();



        cad.setVisible(true);

        JInternalFrame jif = new JInternalFrame();

        jif.add(cad);
        jif.pack();
        jif.setVisible(true);
        jif.setClosable(true);
        this.jdpPrincipal.add(jif);
    
}//GEN-LAST:event_jMenuItem1ActionPerformed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed

    CadastroCurso cad = new CadastroCurso();
    
      cad.setVisible(true);

        JInternalFrame jif = new JInternalFrame();

        jif.add(cad);
        jif.pack();
        jif.setVisible(true);
        jif.setClosable(true);
        this.jdpPrincipal.add(jif);
}//GEN-LAST:event_jMenuItem2ActionPerformed

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed

    Sobre sobre = new Sobre();

    sobre.setVisible(true);

    JInternalFrame jif = new JInternalFrame();

    jif.add(sobre);
    jif.pack();
    jif.setVisible(true);
    jif.setClosable(true);
    jif.setTitle("Sobre");
    this.jdpPrincipal.add(jif);

}//GEN-LAST:event_jMenuItem4ActionPerformed

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
    
    DivulgarNotas painel = new DivulgarNotas();
    
    abreNovaJanelaInterna(painel, "Divulgação de Notas");
    
}//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    public static javax.swing.JDesktopPane jdpPrincipal;
    // End of variables declaration//GEN-END:variables
}
